﻿using System;

namespace HalconDotNet
{
	// Token: 0x02000086 RID: 134
	internal class HDevParamGuard : IDisposable
	{
		// Token: 0x06001DDD RID: 7645 RVA: 0x000B4F48 File Offset: 0x000B3148
		public HDevParamGuard(IntPtr threadHandle, bool global)
		{
			this.mThreadHandle = threadHandle;
			this.mGlobal = global;
			this.mReferenceCount = 0;
			if (this.mGlobal)
			{
				HDevThread.HCkHLib(HalconAPI.HXThreadLockGlobalVar(this.mThreadHandle));
				return;
			}
			IntPtr intPtr;
			HDevThread.HCkHLib(HalconAPI.HXThreadLockLocalVar(this.mThreadHandle, out intPtr));
			this.mReferenceCount = intPtr.ToInt32();
		}

		// Token: 0x06001DDE RID: 7646 RVA: 0x000B4FA8 File Offset: 0x000B31A8
		public bool IsAvailable()
		{
			return this.mGlobal || this.mReferenceCount > 1;
		}

		// Token: 0x06001DDF RID: 7647 RVA: 0x000B4FBD File Offset: 0x000B31BD
		public void Dispose()
		{
			if (this.mGlobal)
			{
				HDevThread.HCkHLib(HalconAPI.HXThreadUnlockGlobalVar(this.mThreadHandle));
				return;
			}
			HDevThread.HCkHLib(HalconAPI.HXThreadUnlockLocalVar(this.mThreadHandle));
		}

		// Token: 0x0400114F RID: 4431
		protected IntPtr mThreadHandle;

		// Token: 0x04001150 RID: 4432
		protected bool mGlobal;

		// Token: 0x04001151 RID: 4433
		protected int mReferenceCount;
	}
}
